package com.javalong.affairs.module.renwujinzhang.activity;

import android.content.Context;
import android.content.Intent;

import com.javalong.affairs.R;
import com.javalong.affairs.base.activity.ToolbarActivity;
import com.javalong.affairs.base.constant.BundleKey;
import com.javalong.affairs.base.constant.DataType;
import com.javalong.affairs.base.constant.MapKey;
import com.javalong.affairs.base.constant.RequestKey;
import com.javalong.affairs.base.data.AllData;
import com.javalong.affairs.base.model.User;
import com.javalong.affairs.base.ui.SimplePullRefreshList;
import com.javalong.affairs.module.renwujinzhang.adapter.UserAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by 杨观回 on 2016/2/28 0028.
 */
public class SupervisesActivity extends ToolbarActivity {
    private SimplePullRefreshList lv_user;
    private UserAdapter adapter;
    private int taskId = 0;
    private List<User> userList;


    @Override
    protected void initLayout() {
        setContentView(R.layout.activity_users);
    }

    @Override
    protected void initData() {
        taskId = getIntent().getIntExtra(BundleKey.ID, 0);
        lv_user = (SimplePullRefreshList) findViewById(R.id.lv_user);
        userList = AllData.GetInstance().appendListData(
                R.string.data_tracktask_detail_supervises, new ArrayList<User>());
        adapter = new UserAdapter(this, userList);
        lv_user.setAdapter(adapter);
        lv_user.initData(getMapData());
        lv_user.refresh();
        getSupportActionBar().setTitle("监督人列表");
    }

    private Map<String, Object> getMapData() {
        Map<String, Object> param = new HashMap<String, Object>();
        param.put(MapKey.ACTION_NAME, "Task");
        param.put(MapKey.METHOD_NAME, "outList_detail_superviseList");
        param.put(MapKey.DATA_RESID, R.string.data_tracktask_detail_supervises);
        param.put(MapKey.DATA_TYPE, DataType.LIST_USER);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(RequestKey.ID, taskId);
        param.put(MapKey.REQUEST_PARAMS, params);
        return param;
    }

    public static void toThisActivity(Context context, int id) {
        Intent intent = new Intent();
        intent.setClass(context, SupervisesActivity.class);
        intent.putExtra(BundleKey.ID, id);
        context.startActivity(intent);
    }
}